	clear matrix 
	clear
	set more off
	set seed 123456789
	capture log close
	log using "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Birthrate\Log_birthrate_prepsm.log", replace  // created a new log file 
	
	cd "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\Analysis Feb 2021\Analysis for 2018\Prepsm\Birthrate"  // setting the current directory
	clear
	
	use "C:\Users\Patron\OneDrive - UW-Madison\Graduate School\Academics\Fall 2020\PA 888 Social Policy\SP\PBS Processed Data\All provinces and regions\1314 and 1819 Combined Feb 2021\prepsm_birthrate_till_2018_vf.dta", replace
	
	
	
	keep if birth_year >= 2011
	keep if birth_year <= 2018
	
	keep if population_halves == 1
	
	
*****data for common trend assumption graph	*******

tabstat given_birth_last_three_years if treat == 1, by(birth_year)
tabstat given_birth_last_three_years if treat == 0, by(birth_year)

tab birth_year

*******testing common trend assumption via regression***************

gen time_trend = birth_year - 2011
gen inter_trend = time_trend*treat

local outputfile_common_trend commontrend_reg_bottom1.xls
set seed 12345678

bootstrap, reps(200): reg given_birth_last_three_years treat time_trend inter_trend  hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source if time == 0, cluster(district) robust
outreg2 using `outputfile_common_trend'


//creating dummy variable for each year for year fixed effects
 xi i.birth_year


*********DiD Estimations Tables for delivery location**************

local outputfile_dd_estimations did_delivery_bottom1.xls
set seed 123456789
bootstrap, reps(200): reg given_birth_last_three_years time treat did_estimator, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg given_birth_last_three_years time treat did_estimator _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'

set seed 123456789
bootstrap, reps(200): reg given_birth_last_three_years time treat did_estimator hh_head_gender head_employment_status head_highest_grade hh_annual_income hh_annual_transfers hh_annual_exp_food_nondurables hh_annual_exp_durables hh_size dwelling_type occupancy_status distance_to_drinking_water drainage_sewerage_connection garbage_hh garbage_neighborhood drinking_water_source _Ibirth_yea*, cluster(district) robust
outreg2 using `outputfile_dd_estimations'




log close

